package com.example.demo.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import com.example.demo.entity.Student;
import com.example.demo.mapper.StudentMapper;
import com.example.demo.service.StudentService;

@Service
@Transactional
public class StudentServiceImpl implements StudentService{

	@Autowired
	private StudentMapper studentMapper;
	
	private List<Student> studentlist;
	
	private Student student1;
	
	@Override
	public int addStudent(Student student) {
		// TODO Auto-generated method stub
		return studentMapper.insertStudent(student);
	}

	@Override
	public int delStudent(Integer sid) {
		// TODO Auto-generated method stub
		return studentMapper.deleteStudent(sid);
	}

	@Override
	public int updateStudent(Student student) {
		// TODO Auto-generated method stub
		return studentMapper.updateStudent(student);
	}

	@Override
	public List<Student> selectStudent() {
		// TODO Auto-generated method stub
		studentlist=new ArrayList<Student>();
		studentlist=studentMapper.selectStudent();
		return studentlist;
	}

	@Override
	public Student selectOneStudent(Integer sid) {
		// TODO Auto-generated method stub
		student1= new Student();
		student1= studentMapper.selectOneStudent(sid); 
		return student1;
	}


}
